
//继承：对共性进行抽取，实现代码的复用
//先进性静态代码块 -->实例代码块-->构造方法
//父类优先子类执行  静态的最先执行
class Animal {
    public String name;
    public int age;

    public void eat() {
        System.out.println(name + " eating");
    }
    public Animal() {

    }
    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
        System.out.println("带有2个参数的构造方法");
    }
}

class Bird extends Animal {
    public Bird() {
        super();//不写也行 编译器会默认帮你加上
    }
}

//    子类         父类
class Dog extends Animal {

    public Dog() {
        super("hh",18);
    }
    public void wangwang() {
        System.out.println(name + " wangwang");
    }
}
class  Cat extends  Animal {

    public Cat() {

    }
    public int size;
    public Cat(String name, int age, int size) {
        super(name,age);//super在子类构造方法内，调用父类构造方法时，必须放第一行
        this.size = size;
    }
    public Cat(String name,int age) {
        super(name,age);
        //this("1",2,3);
        //super和this调用构造方法时候，不能同时出现
    }

    public void miaomiao() {
        System.out.println(name + " miaomiao");
    }
}
public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "lala";
        dog.wangwang();
        System.out.println("==============");

        Cat cat = new Cat();
        cat.name = "kaka";
        cat.miaomiao();

    }

}
